package com.herr.mybatis.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Date;

/**
 * @author liuzh
 */
@Controller
public class IndexController {
    @RequestMapping(value = {"", "/index"})
    public ModelAndView dicts(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
        String name =request.getParameter("name");

        //name = URLDecoder.decode(request.getParameter("name"),"iso-8859-1");

        //name = new String(name.getBytes("UTF-8"), "ISO8859-1");
        //name = URLDecoder.decode(request.getParameter("name"),"UTF-8");
        //String name = new String(request.getParameter("name").getBytes("iso-8859-1"), "utf-8");
        ModelAndView mv = new ModelAndView("index");
        mv.addObject("now", new Date());
        mv.addObject("name", name);
        return mv;
    }
}
